6eaee9c1a58bb174883ca1e7c7bcdfa4b6fcc957,src/main/java/org/fife/ui/rtextarea/RTextAreaEditorKit.java,LineMoveAction,moveLineUp,#RTextArea#number#,1710

Before Change


			if (line==lineCount-1) {
				text += '\n';
			}
			doc.insertString(start2, text, null);
			//caretOffset = Math.min(start2+caretOffset, end2-1);
			textArea.setCaretPosition(start2+caretOffset);
		}

After Change



		}

		private void moveLineUp(RTextArea textArea, int line, int moveCount)
									throws BadLocationException {

			Document doc = textArea.getDocument();
			Element root = doc.getDefaultRootElement();
			Element elem = root.getElement(line);
			int start = elem.getStartOffset();

			int endLine = line + moveCount - 1;
			elem = root.getElement(endLine);
			int end = elem.getEndOffset();
			int lineCount = textArea.getLineCount();
			boolean movingLastLine = false;
			if (endLine == lineCount - 1) {
				movingLastLine = true;
				end--;
			}

			int insertLine = Math.max(line - 1, 0);

			textArea.beginAtomicEdit();
			try {

				System.out.println("*** " + start + ", " + (end - start));
				String text = doc.getText(start, end - start);
				if (movingLastLine) {
					text += '\n';
				}
				System.out.println("*** *** '" + text + "'");
				doc.remove(start, end - start);
				System.out.println("*** *** *** good");

				int insertOffs = textArea.getLineStartOffset(insertLine);
				doc.insertString(insertOffs, text, null);
				textArea.setSelectionStart(insertOffs);
				int selEnd = insertOffs + text.length() - 1;
				textArea.setSelectionEnd(selEnd);
				if (movingLastLine) { // Remove the artifically-added newline
					doc.remove(doc.getLength() - 1, 1);
				}

			} finally {